/**
 * @author DongPing
 * 2022/1/22 11:28
 *
 * 将分页查询接口返回的数据转化为下拉选择数据
 *
 * */
import {TSelectOptions} from "@/common-data-source/type";

export function parsePageResponseToSelect(response: any, valueAttributeName: string = 'code', nameAttributeName: string = 'name'): {total: number, data: TSelectOptions} {
	const data: TSelectOptions = [];
	for(const item of response.result.content) {
		data.push({
			value: item[valueAttributeName],
			name: item[nameAttributeName]
		})
	}
	return {
		total: response.result.totalElements,
		data
	}
}
